# _Item_
#
#Takes:
#   :id  => unique item id
#   :type => type of item
#   :price => price of the item

class Item
  DATA_FILE = RAILS_ROOT + "/data.yml"
  attr_accessor :id, :type, :price
  def initialize(attributes)
    @id = attributes['id']
    @type = attributes ['type']
    @price = attributes ['price']
  end
  def to_s
    "Item #{@id} is a #{@type}: Price $#{@price}"
  end

  #Returns an array of all items sold in the store
  def self.load_item_data
    YAML.load_file(DATA_FILE).collect do |item_hash|
      Item.new(item_hash)
    end
  end
end